package com.pattern.observer.jdkdemo;

import java.util.Observable;
import java.util.Observer;

/**
 * Observer接口是观察者
 * 这里模拟粉丝，他们关注了一个博主后，每次博主发布新帖子，都会收到通知
 */
public class Fan implements Observer {
    private String name;

    public Fan(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void update(Observable o, Object arg) {
        Blogger blogger = (Blogger)o;
        Blog blog = (Blog)arg;

        System.out.println("================================================");
        System.out.println(name + "关注的博主：" + blogger.getName() + "发布了新内容，标题为：《" + blog.getName() + "》，已添加进未读列表");
    }
}
